package com.eyalsh.data_structures.linkedLists.basic;

/**
 * @author Eyal Shalev
 * 
 */
public class LinkedListNode<T> implements
		com.eyalsh.data_structures.linkedLists.LinkedListNode<T> {

	/**
	 * Constructor for LinkedListNode<br>
	 * 
	 */
	public LinkedListNode(T data, LinkedList<T> list) {
		data(data);
		list(list);
	}

	private LinkedList<T> list;

	private void list(LinkedList<T> value) {
		list = value;
	}

	public LinkedList<T> list() {
		return list;
	}

	private T data = null;

	private void data(T value) {
		data = value;
	}

	@Override
	public T data() {
		return data;
	}

	private LinkedListNode<T> next = null;

	protected void next(LinkedListNode<T> value) {
		next = value;
	}

	@Override
	public LinkedListNode<T> next() {
		return next;
	}

	public void append(T data) {
		LinkedListNode<T> temp = next();
		next(new LinkedListNode<T>(data, list()));
		next().next(temp);
	}

	@Override
	public boolean hasNext() {
		return next() != null;
	}

}
